/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include <基本类型.h>
#include <map>
#include <vector>
#include <algorithm> 
#include <string>
#include <字符串转换.h>

/*typedef enum {
	e_大括号,
	e_圆括号,
	e_方括号,
	e_括号符end
}E_括号符;

typedef enum {
	e_指针,
	e_成员,
	e_访问符end
}E_访问符;

typedef enum {
	e_非,
	e_波折号,
	e_前加加,
	e_前减减,
	e_算术运算符L1end
}E_算术运算符L1;

typedef enum {
	e_后加加,
	e_后减减,
	e_类型转换,
	e_取指针,
	e_类型大小,
	e_算术运算符L2end
}E_算术运算符L2;

typedef enum {
	e_乘,
	e_除,
	e_算术运算符L3end
}E_算术运算符L3;

typedef enum {
	e_加,
	e_减,
	e_算术运算符L4end
}E_算术运算符L4;

typedef enum {
	e_左移,
	e_右移,
	e_算术运算符L5end
}E_算术运算符L5;

typedef enum {
	e_小于,
	e_小于等于,
	e_大于,
	e_大于等于,
	e_关系运算符L1end
}E_关系运算符L1;

typedef enum {
	e_等于,
	e_不等于,
	e_关系运算符L2end
}E_关系运算符L2;

typedef enum {
	e_按位与,
	e_异或,
	e_按位或,
	e_位运算符end
}E_位运算符_带优先级;

typedef enum {
	e_逻辑且,
	e_逻辑或,
	e_逻辑运算符end
}E_逻辑运算符_带优先级;

typedef enum {
	e_三目运算符,
	e_三目运算符end
}E_三目运算符_带优先级;

typedef enum {
	e_加等于,
	e_减等于,
	e_乘等于,
	e_除等于,
	e_余等于,
	e_左移等于,
	e_右移等于,
	e_且等于,
	e_或等于,
	e_异或等于,
	e_赋值,

	e_运算符end
}E_赋值运算符;

enum E_操作符类型 {
	e_括号,
	e_访问符,
	e_算术运算符L1,
	e_算术运算符L2,
	e_算术运算符L3,
	e_算术运算符L4,
	e_算术运算符L5,

	e_关系运算符L1,
	e_关系运算符L2,

	e_位运算符,
	e_逻辑运算符,
	e_type_三目运算符,
	e_赋值运算符,

	e_空,
};*/



struct S_运算符 {
	uint32			赋值运算符;
	std::wstring	运算符名称;
};

struct S_运算符分割位置 {
	uint32	运算符枚举;
	uint32	字符串位置;
};


typedef enum {
	e_函数,
	e_结构,
	e_变量,
}E_代码块类型;

typedef enum {
	e_i8,
	e_u8,
	e_i16,
	e_u16,
	e_i32,
	e_u32,
	e_i64,
	e_u64,
	e_i128,
	e_u128,
	e_i256,
	e_u256,
	e_i512,
	e_u512,
	e_f16,
	e_f32,
	e_f64,
	e_f128,
}E_基础类型;

typedef enum {
	//0
	e_大括号,
	e_圆括号,
	e_方括号,
	//1
	e_指针,
	e_成员,
	//2
	e_取负,
	e_非,
	e_按位取反,			//波折号
	e_前加加,
	e_前减减,
	//3
	e_后加加,
	e_后减减,
	e_取指针,
	e_类型转换,
	e_类型大小,
	//4
	e_乘,
	e_除,
	//5
	e_加,
	e_减,
	//6
	e_左移,
	e_右移,
	//7
	e_小于,
	e_小于等于,
	e_大于,
	e_大于等于,
	//8
	e_等于,
	e_不等于,
	//9
	e_按位与,
	//10
	e_异或,
	//11
	e_按位或,
	//12
	e_逻辑且,
	//13
	e_逻辑或,
	//14
	e_三目运算符,
	//15
	e_加等于,
	e_减等于,
	e_乘等于,
	e_除等于,
	e_余等于,
	e_左移等于,
	e_右移等于,
	e_且等于,
	e_或等于,
	e_异或等于,
	e_赋值,

	//16
	e_逗号,
	e_运算符end,
}E_运算符;

typedef enum {
	e_运算符_L0_b = e_大括号,
	e_运算符_L1_b = e_指针,
	e_运算符_L2_b = e_取负,
	e_运算符_L3_b = e_后加加,
	e_运算符_L4_b = e_乘,
	e_运算符_L5_b = e_加,
	e_运算符_L6_b = e_左移,
	e_运算符_L7_b = e_小于,
	e_运算符_L8_b = e_等于,
	e_运算符_L9_b = e_按位与,
	e_运算符_L10_b = e_异或,
	e_运算符_L11_b = e_按位或,
	e_运算符_L12_b = e_逻辑且,
	e_运算符_L13_b = e_逻辑或,
	e_运算符_L14_b = e_三目运算符,
	e_运算符_L15_b = e_加等于,
}E_运算符优先级区间begin;
typedef enum {
	e_运算符_L0_e = e_方括号,
	e_运算符_L1_e = e_成员,
	e_运算符_L2_e = e_前减减,
	e_运算符_L3_e = e_类型大小,
	e_运算符_L4_e = e_除,
	e_运算符_L5_e = e_减,
	e_运算符_L6_e = e_右移,
	e_运算符_L7_e = e_大于等于,
	e_运算符_L8_e = e_不等于,
	e_运算符_L9_e = e_按位与,
	e_运算符_L10_e = e_异或,
	e_运算符_L11_e = e_按位或,
	e_运算符_L12_e = e_逻辑且,
	e_运算符_L13_e = e_逻辑或,
	e_运算符_L14_e = e_三目运算符,
	e_运算符_L15_e = e_赋值,
}E_运算符优先级区间end;

typedef enum {
	e_运算符_L0,
	e_运算符_L1,
	e_运算符_L2,
	e_运算符_L3,
	e_运算符_L4,
	e_运算符_L5,
	e_运算符_L6,
	e_运算符_L7,
	e_运算符_L8,
	e_运算符_L9,
	e_运算符_L10,
	e_运算符_L11,
	e_运算符_L12,
	e_运算符_L13,
	e_运算符_L14,
	e_运算符_L15,
}E_运算符优先级;



struct S_操作符 {
	uint32			符ID;
	std::wstring	符名称L;
	std::wstring	符名称R;
};

struct S_操作符分割位置 {
	uint32	符ID;
	uint32	字符串位置begin;
	uint32	字符串位置end;
};

struct S_括号代码块 {
	S_操作符分割位置			符;
	std::vector<S_括号代码块>	块;
};


struct S_表达式 {
	std::vector<S_表达式*> m_子表达式;

	std::wstring	name前;
	E_运算符优先级	操作符优先级;
	uint32			操作符;
	std::wstring	name后;
};


struct S_操作符表达段 {
	E_运算符		操作符枚举;
	std::wstring	操作符名称;
};


typedef bool(*f_JIT_接口函数指针)(E_JIT_FunParam* 参数, uint8 参数数量);





typedef enum : uint64 {
	
	e_扩展_节点 = DEF_字符串拼接ID('e', 'x', 'n', 'o', 'd', 'e', '\0', '\0'),
	e_扩展_物体构建 = DEF_字符串拼接ID('o', 'b', 'b', 'u', 'i', 'l', 'd', '\0'),
	e_扩展_变换操作 = DEF_字符串拼接ID('B', 'H', 'o', 'p', 's', '\0', '\0', '\0'),
	e_扩展_场景更新 = DEF_字符串拼接ID('C', 'J', 'G', 'X', '\0', '\0', '\0', '\0'),

	//e_扩展_渲染线管 = DEF_字符串拼接ID('X', 'R', 'X', 'G', '\0', '\0', '\0', '\0'),
	//e_扩展_材质着色 = DEF_字符串拼接ID('C', 'Z', 'Z', 'S', '\0', '\0', '\0', '\0'),

}E_扩展类型;

enum E_工作区类型 : uint8 {
	e_库,

	e_3D视口,
	e_2D视口,

	e_时间轴,
	e_节点视口,
	e_曲线视口,

	e_非编视口,
	e_材质节点视口,
	e_渲染合成视口,
	e_表格视口,
	e_文本编辑视口,
	e_视频图像,
	e_UI视口,
	e_设置视口,
	e_大纲视口,

	e_模块视口,
	e_终端视口,


	e_属性面板,
	e_状态条,
	e_后台,
};



struct S_插件模块 {
	E_扩展类型		m_Type;
	void*			m_Object;
	std::u16string	m_Name;
	std::vector<std::u16string> m_注册路径;
	E_工作区类型				m_注册工作区;

	S_插件模块(){}
	~S_插件模块(){}
};

//template<typename T>
//struct S_插件模块实例 {
//	E_扩展类型		m_Type;
//	T*				m_Object;
//	std::u16string	m_Name;
//	std::vector<std::u16string> m_注册路径;
//};

struct S_插件 {
	std::u16string	m_Name;
	uint64			m_库;
	bool			m_链接源码;

	std::map<std::u16string, S_插件模块> m_模块;
	S_插件() : m_库(0), m_链接源码(false) {}
	~S_插件(){}
};



typedef bool(*f_plugin_加载卸载函数指针)(std::map<std::u16string, S_插件模块>& 模块);





